[an error occurred while processing this directive]
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // // Project: Talina Gaming System (TgS) (∂) // File: TgS Collision - Triangle [Util].cpp // Author: Andrew Aye (EMail: andrew.aye@gmail.com, Web: http://www.andrewaye.com) // Version: 3.11 // // ------------------------------------------------------------------------------------------------------------------------------ // // // Copyright: © 2002-2008, Andrew Aye. All Rights Reserved. // // This software is free for non-commercial use. Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // Redistributions of source code must retain this copyright notice, this list of conditions and the following disclaimers. // Redistributions in binary form must reproduce this copyright notice, this list of conditions and the following // disclaimers in the documentation and other materials provided with the distribution. // // Neither the names of the copyright owner nor the names of its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // The intellectual property rights of the algorithms used reside with Andrew Aye. You may not use this software, in whole or // in part, in support of any commercial product without the express written consent of the author. // // There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is". // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // namespace TGS { // START TGS /////////////////////////////////////////////////////////////////////////////////////////////////////// namespace COL { // START COL /////////////////////////////////////////////////////////////////////////////////////////////////////// // ============================================================================================================================== // // ---- ClipTri --------------------------------------------------------------------------------------------------------------- // // Input: tgET0: Edge Triangle primitive - F_Clip-space is the region defined by the infinite extrusion along the normal. // Input: tgCL: Contains a segment list that is to be clipped in-place. // Output: tgCL: The resulting segment list. // Return: Result Code. // ------------------------------------------------------------------------------------------------------------------------------ // template <typename TYPE, int DIM> TgRESULT F_Clip( PC_(CLIP_LIST,DIM) ptgCL, CR_(ETRI,DIM) tgET0 ) { TTgPLANE<TYPE,DIM> tgPlane; tgPlane.Set( MATH::F_CX( tgET0.Query_Normal(), tgET0.Query_Edge0() ), tgET0.Query_Point0() ); if (TgFAILED(F_Clip( ptgCL, tgPlane ))) { return (TgE_FAIL); }; if (0 == ptgCL->m_niPoint) return (TgS_OK); tgPlane.Set( MATH::F_CX( tgET0.Query_Normal(), tgET0.Query_Edge1() ), tgET0.Query_Point1() ); if (TgFAILED(F_Clip( ptgCL, tgPlane ))) { return (TgE_FAIL); }; if (0 == ptgCL->m_niPoint) return (TgS_OK); tgPlane.Set( MATH::F_CX( tgET0.Query_Normal(), tgET0.Query_Edge2()), tgET0.Query_Point2() ); if (TgFAILED(F_Clip( ptgCL, tgPlane ))) { return (TgE_FAIL); }; return (TgS_OK); }; template TgRESULT F_Clip( PC_TgF4CLIP_LIST, CR_TgF4ETRI ); // ============================================================================================================================== // // ---- F_Is_Seperating_Axis ------------------------------------------------------------------------------------------------------ // // Input: tgPT0, tgPT1: Point Triangle primitives // Input: tvAxis: Axis of SeparationS being tested // Return: True of the two triangles are separated, false otherwise. // ------------------------------------------------------------------------------------------------------------------------------ // template <typename TYPE, int DIM> TgBOOL F_Is_Seperating_Axis( M_(VECTOR,DIM) tvAxis, CR_(PTRI,DIM) tgPT0, CR_(PTRI,DIM) tgPT1 ) { TgASSERT(MATH::F_LSQ( tvAxis ) > LIMITS<TYPE>::EPSILON) TYPE tyMin0,tyMax0, tyMin1,tyMax1, tyTMP; tyMin0 = tyMax0 = MATH::F_DOT(tvAxis,tgPT0.Query_Point0()); tyMin1 = tyMax1 = MATH::F_DOT(tvAxis,tgPT1.Query_Point0()); tyTMP = MATH::F_DOT(tvAxis,tgPT0.Query_Point1()); tyMin0 = P::FSEL( tyMin0 - tyTMP, tyTMP, tyMin0 ); tyMax0 = P::FSEL( tyTMP - tyMax0, tyTMP, tyMax0 ); tyTMP = MATH::F_DOT(tvAxis,tgPT0.Query_Point2()); tyMin0 = P::FSEL( tyMin0 - tyTMP, tyTMP, tyMin0 ); tyMax0 = P::FSEL( tyTMP - tyMax0, tyTMP, tyMax0 ); tyTMP = MATH::F_DOT(tvAxis,tgPT1.Query_Point1()); tyMin1 = P::FSEL( tyMin1 - tyTMP, tyTMP, tyMin1 ); tyMax1 = P::FSEL( tyTMP - tyMax1, tyTMP, tyMax1 ); tyTMP = MATH::F_DOT(tvAxis,tgPT1.Query_Point2()); tyMin1 = P::FSEL( tyMin1 - tyTMP, tyTMP, tyMin1 ); tyMax1 = P::FSEL( tyTMP - tyMax1, tyTMP, tyMax1 ); return ((tyMin0 >= tyMax1) || (tyMin1 >= tyMax0)); } template TgBOOL F_Is_Seperating_Axis( M_TgF4VECTOR, CR_TgF4PTRI, CR_TgF4PTRI ); // ============================================================================================================================== // }; // END COL ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }; // END TGS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////[an error occurred while processing this directive]